First Step into Quantum Computing
- Difficulties: Beginner
- QPU time usage: 11s
Welcome, hackers! We're thrilled to have you for the workshop. The main goal of this introductory hands-on is to make you ready for your quantum journey by 1) guiding you how to install qiskit 2) how to create IBM Cloud account and prepare api_key and crn to use a real quantum computer and 3) make your first quantum circuit, 4) solve a quantum state quiz and 5) Run you circuits on the real quantum computer and plot the result.
1. First things first: Qiskit
What is Qiskit
The Qiskit SDK is a high performance software stack built to help developers and researchers harness the full power of quantum computers at the utility scale and beyond. At its core is the Qiskit SDK, an open source software development kit for working with quantum computers at the level of extended quantum circuits. Operators and primitives. The Qiskit SDK allows anyone to get optimal performance from real quantum computers using their preferred computing environment.
Beyond the SDK, Qiskit also includes a suite of high performance tools and services like Qiskit Runtime Service, which enables optimized computations at IBM quantum computers through the cloud using primitives that manage error mitigation. The Qiskit Transpiler service, which provides state of the art heuristic and AI powered methods that boost performance for common quantum circuit optimization tasks.
Qiskit functions, a catalog of IBM and third party services that make it easy to optimize workloads and leverage Qiskit for industry use cases. Whether you're a quantum software developer, a quantum experimentalist, a computational scientist, or just looking to get started Qiskit’s modular, flexible framework lets you work at the abstraction level that best suits your needs.
Qiskit is designed for extensibility and customization, so you can extract industry leading performance and tackle new kinds of problems. A high performance code base means a Qiskit SDK works faster, uses less memory, and delivers better results than ever before. And Qiskit also introduces you to a vast community of users and developers who are eager to welcome you and help answer your questions. First launched in 2019, the Qiskit advocate program is a global, community-centered initiative that recruits quantum computing professionals and enthusiasts from all over the world. Over the years, advocates have gone on to become recognized leaders in the quantum community. Want to be a next quantum leader? Don't hesitate to apply - here
Install Qiskit
First, check that the version of Python you are using in your environment is python>=3.10, to make sure that it is compatible with the latest Qiskit version we will use
from platform import python_version
print(python_version())
If that is not the case, you can upgrade it using your preferred tool. If you are unsure how to do it, some recommended options are:
- MacOS: Homebrew
- Linux:
sudo apt-get update
A detailed guide on how to upgrade Python depending on your OS is detailed here: How to update Python
For more information take a look at the QGSS(Qiskit Global Summer School) 2025 wiki: https://github.com/qiskit-community/qgss-2025/wiki/Jupyter-Notebook-Environment-(Local-and-Online)
You can verify your installation by running the cell below. If you installed correctly, it will return the qiskit version.
# Added by doQumentation — required packages for this notebook
!pip install -q numpy qiskit
%pip install 'qiskit[visualization]'
%pip install qiskit-ibm-runtime
%pip install qiskit-aer
import qiskit
print(f"Qiskit version: {qiskit.__version__}")
Troubleshooting
If the previous cell raised an error, you can opt to install Qiskit in a virtual environment (two suggested methods follow). If you have no errors, you can ignore this cell and proceed to the next one.
Here we propose two different methods to set up a virtual environment to install Qiskit.
- Using venv, as explained in the Qiskit installation guide.
- Using conda, as explained in this video of Coding with Qiskit.
2. Set up your IBM Cloud account
To use a real quantum computer, you need an api key - a main entrance ticket to the cloud and a crn - token that will bring your resources to you by setting your account.
Set up your account as follows:
- Go to the IBM Quantum® Platform.
- Go to the top right corner (as shown in the above picture), create your API token, and copy it to a secure location.
- In the next cell, replace
deleteThisAndPasteYourAPIKeyHerewith your API key. - Go to the bottom left corner (as shown in the above picture) and create your instance. Make sure to choose the open plan.
- After the instance is created, copy its associated CRN code. You may need to refresh to see the instance.
- In the cell below, replace
deleteThisAndPasteYourCRNHerewith your CRN code.
See this guide for more details on how to set up your IBM Cloud® account.
⚠️ Note: Treat your API key as you would a secure password. See the Cloud setup guide for more information about using your API key in both secure and untrusted environments.
Additionally, if you are a member of the IBM partner network university, please use your institution's email address for your IBM ID to receive the partner benefit.
from qiskit_ibm_runtime import QiskitRuntimeService
# Save your API key and crn and have access to the quantum computers
your_api_key = "deleteThisAndPasteYourAPIKeyHere"
your_crn = "deleteThisAndPasteYourCRNHere"
QiskitRuntimeService.save_account(
channel="ibm_cloud",
token=your_api_key,
instance=your_crn,
overwrite=True
)
# Check that the account has been saved properly
service = QiskitRuntimeService()
service.saved_accounts()
# See backends you can use
service.backends()
3. Your first Quantum Circuit
Quantum circuits
The fundamental unit of Qiskit is the quantum circuit, which is a series of instructions that a quantum computer can use to work with quantum bits of information, also known as qubits. These qubits have special properties that enable quantum computers to approach problems differently than how your laptop or iPhone might. Qiskit is rapidly advancing as a technology -- while you can still manually design your quantum circuits and decide how you want it to run (and there are plenty of good reasons to do so), IBM Quantum also provides you with tools that simplify the process. For the sake of learning, we are going to design a very simple circuit and run it on a simulator.
We're breezing through this overview because, honestly, we could spend hours just explaining the basics of quantum information and computation. In fact, IBM Quantum has done this already, producing a written course and a series of video lectures devoted to the topic. If you need a refresher, check them out!
from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector
from qiskit.visualization import plot_state_qsphere
from qiskit_aer import AerSimulator
from qiskit_ibm_runtime import QiskitRuntimeService
from qiskit_ibm_runtime import SamplerV2 as Sampler
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit.transpiler import generate_preset_pass_manager
from qiskit.visualization import array_to_latex
from qiskit.visualization import plot_distribution
import numpy as np
from numpy import sqrt
Basic Operations on Qubits and Measurements
Writing down single-qubit states
Let us start by looking at a single qubit. The main difference between a classical bit, which can take the values 0 and 1 only, is that a quantum bit, or qubit, can be in the states , , as well as a linear combination of these two states. This feature is known as superposition, and allows us to write the most general state of a qubit as:
If we were to measure the state of this qubit, we would find the result with probability , and the result with probability . As you can see, the total probability is , meaning that we will indeed measure either or , and no other outcomes exists.
In addition to , you might have noticed another parameter above. The variable indicates the relative quantum phase between the two states and . As we will discover later, this relative phase is quite important. For now, it suffices to note that the quantum phase is what enables interference between quantum states, resulting in our ability to write quantum algorithms for solving specific tasks.
Visualizing quantum states
We visualize quantum states throughout this exercise using what is known as a qsphere. Here is how the qsphere looks for the states and , respectively. Note that the top-most part of the sphere represents the state , while the bottom represents